import requests

#
# url = "http://www.bilibili.com/"
# # 使用requests.get()函数发送GET请求，并将响应保存在resp变量中。
# resp = requests.get(url)
# # resp.text会返回一个字符串，包含了网页源代码
# resp.encoding = "utf-8"
# print(resp.text)


# content = input("请输入你想要搜索的内容：")
# url = f"https://www.sogou.com/web?query={content}"
#
# headers = {
#     "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0"
# }
# # 不伪装容易被拦截
# # resp = requests.get(url)
# # 用浏览器发送的useragent伪装
# resp = requests.get(url, headers=headers)
# # print(resp.text)
#
# print(resp.request.headers)


# url = "https://fanyi.baidu.com/sug"
# data = {
#     "kw": input("请输入一个单词")
# }
# # 返回的响应是json格式
# resp = requests.post(url, data=data)
# # print(resp.text)  # 打印响应的json成字符串，看不懂
# print(resp.json())   # resp.json() 方法会将响应的 JSON 数据解析成 Python 中的字典类型
# # print(resp.json()['data'])   # 可以向外一层一层的拿数据


url = "https://movie.douban.com/j/chart/top_list"
params = {
    "type": "13",
    "interval_id": "100:90",
    "action": "",
    "start": "0",
    "limit": "20"
}
headers = {
    "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)"
}

resp = requests.get(url, params=params, headers=headers)
# print(resp.request.url) # 打印返回的url ,对比确认填入参数传递正确
# print(resp.text)
print(resp.json())
